home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / hardware / cpu115 / cputype.pas < prev    next >
Pascal/Delphi Source File  |  1995-02-27  |  7KB  |  260 lines

  1. {$A-,B-,D+,E-,F+,G-,I-,L+,N-,O+,R-,S-,V-,X+}
  2. { --------------------------------------------------------------------------- }
  3. { CPUTYPE.PAS  CPU type detection routines ( Intel & compatible family only ) }
  4. {                                                                             }
  5. { Copyright(c) 1992-95 by B-coolWare.  Written by Bobby Z.                    }
  6. { --------------------------------------------------------------------------- }
  7. { files needed to build project:
  8.  
  9.   HEADER.ASH
  10.   CPU_HL.ASM
  11.   CPUSPEED.ASM
  12.   P5INFO.ASM                                      }
  13.  
  14. unit CPUType;
  15.  
  16. interface
  17.  
  18. const  i88     =  $0000;    { Intel 8088 }
  19.        i86     =  $0001;    { Intel 8086 }
  20.        V20     =  $0002;    { NEC V20 }
  21.        V30     =  $0003;    { NEC V30 }
  22.        i188    =  $0004;    { Intel 80188 }
  23.        i186    =  $0005;    { Intel 80186 }
  24.        i286    =  $0006;    { Intel 80286 }
  25.        i386sxr =  $0007;    { Intel 80386sx real mode }
  26.        i386sxv =  $0107;    { Intel 80386sx V86 mode }
  27.        i386dxr =  $0008;    { Intel 80386dx real mode }
  28.        i386dxv =  $0108;    { Intel 80386dx V86 mode }
  29.        i386slr =  $0009;        { IBM 80386SL real mode }
  30.        i386slv =  $0109;        { IBM 80386SL V86 mode }
  31.        i486sxr =  $000A;    { Intel i486sx real mode }
  32.        i486sxv =  $010A;    { Intel i486sx V86 mode }
  33.        i486dxr =  $000B;    { Intel i486dx real mode }
  34.        i486dxv =  $010B;    { Intel i486dx V86 mode }
  35.        c486slcr=  $000C;    { Cyrix 486slc real mode }
  36.        c486slcv=  $010C;    { Cyrix 486slc V86 mode }
  37.        c486r   =  $000D;    { Cyrix 486sx/dx/dlc real mode }
  38.        c486v   =  $010D;    { Cyrix 486sx/dx/dlc V86 mode }
  39.        i586r   =  $000E;    { Intel Pentium real mode }
  40.        i586v   =  $010E;    { Intel Pentium V86 mode }
  41.        cM1r    =  $000F;    { Cyrix M1 (586) in real mode }
  42.        cM1v    =  $010F;    { Cyrix M1 (586) in V86 mode }
  43.        iP24Dr  =  $0010;    { Intel P24D in real mode }
  44.        iP24Dv  =  $0110;    { Intel P24D in V86 mode }
  45.  
  46.        { these CPUs reported only if tested as Intel 386 and CPU clock > 33MHz
  47.      because Intel does not produce such chips }
  48.        umcU5sxr=  $0013;
  49.        umcU5sxv=  $0113;
  50.        umcU5dxr=  $0014;
  51.        umcU5dxv=  $0114;
  52.  
  53. function CPU_Type : Word; far;
  54.  
  55. function CPU_TypeStr : String;
  56.  
  57. function CoPro_TypeStr : String;
  58.  
  59. function CPUSpeed : Real;
  60.  
  61. function intCPUSpeed : Integer;
  62.  
  63. function isSMMAble : Boolean; far;
  64.  
  65. function checkEmu : Boolean; far;
  66.  
  67. { function checkAMD : Boolean; far; }
  68.  
  69. const
  70.     _CPU  : Byte = 0;
  71.       FPUType : Byte = $FF;
  72.  
  73. implementation
  74.  
  75. const 
  76.       CPUFix  : LongInt = 0;
  77.       Shift   : Word    = 2;
  78.  
  79.       CyrStr  : String[6] = 'Cyrix ';
  80.       IntelStr: String[6] = 'Intel ';
  81.       WeitStr : String[11]= 'Weitek 1167';
  82.       IITStr  : String[4] = 'IIT ';
  83.       andStr  : String[5] = ' and ';
  84.  
  85.       umcU5s  = $13;
  86.       umcU5d  = $14;
  87.  
  88. function CPU_Type; external;
  89.  
  90. function checkEmu; external;
  91.  
  92. { function checkAMD; external; }
  93. {$IFDEF DPMI}
  94. {$L CPU_TP.OBP}
  95. {$ELSE}
  96. {$L CPU_TP}
  97. {$ENDIF}
  98.  
  99. function Speed(CPUId : Byte) : Word; external;
  100. {$IFDEF DPMI}
  101. {$L SPEED_TP.OBP}
  102. {$ELSE}
  103. {$L SPEED_TP}
  104. {$ENDIF}
  105.  
  106. function CheckP5 : Word; far; external;
  107.  
  108. function GetP5Vendor : String; far; external;
  109.  
  110. function GetP5Features : Word; far; external;
  111. {$L P5INFO}
  112.  
  113. function isSMMAble : Boolean; external;
  114. {$L SMM}
  115.  
  116. function Vendor( CPU : Byte ) : String;
  117.  begin
  118.   case CPU of
  119.    $0C,$0D,
  120.    $0F     : Vendor := CyrStr;
  121.    $02,$03 : Vendor := 'NEC ';
  122.    $09     : Vendor := 'IBM ';
  123.    $13,$14 : Vendor := 'UMC ';
  124.   else
  125.    Vendor := IntelStr;
  126.   end;
  127.   if (CPU in [7,8]) then
  128.    if intCPUSpeed > 35 then
  129.     Vendor := 'AMD Am'
  130.    else
  131.     Vendor := 'Intel 80';
  132.  end;
  133.  
  134. procedure checkUMC;
  135.  begin
  136.   if _CPU >= i486sxr then
  137.    if CheckP5 = $423 then
  138.     if Pos('UMC',GetP5Vendor) <> 0 then
  139.      if (GetP5Features and 1) = 1 then
  140.       _CPU := umcU5d
  141.      else
  142.       _CPU := umcU5s;
  143.  end;
  144.  
  145. const
  146.     Models : array[0..15] of String[13] = (
  147.              'DX',
  148.          'DX',
  149.          'SX',
  150.          'DX2/Overdrive',
  151.          'SL',
  152.          'SX2',
  153.          '',
  154.          '',
  155.          'DX4',
  156.          '',
  157.          '',
  158.          '',
  159.          '',
  160.          '',
  161.          '',
  162.          '');
  163.  
  164. function CPU_TypeStr;
  165.  var CPU : Word;
  166. begin
  167.  CPU := CPU_Type;
  168.  _CPU := CPU;
  169.  checkUMC;
  170.  if (_CPU = $0A) and (CPU shr 12 <> 0) then
  171.   begin
  172.    CPU_TypeStr := 'Intel i486'+Models[CPU shr 12];
  173.    exit;
  174.   end;
  175.  case CPU of
  176.   i88      : CPU_TypeStr := Vendor(CPU)+'8088';
  177.   i86      : CPU_TypeStr := Vendor(CPU)+'8086';
  178.   i188     : CPU_TypeStr := Vendor(CPU)+'80188';
  179.   i186     : CPU_TypeStr := Vendor(CPU)+'80186';
  180.   v20      : CPU_TypeStr := Vendor(CPU)+'V20';
  181.   v30      : CPU_TypeStr := Vendor(CPU)+'V30';
  182.   i286     : CPU_TypeStr := Vendor(CPU)+'80286';
  183.   i386sxr,
  184.   i386sxv  : CPU_TypeStr := Vendor(CPU)+'386SX';
  185.   i386slr,
  186.   i386slv  : CPU_TypeStr := Vendor(CPU)+'80386SL';
  187.   i386dxr,
  188.   i386dxv  : CPU_TypeStr := Vendor(CPU)+'386DX';
  189.   i486sxr,
  190.   i486sxv  : CPU_TypeStr := Vendor(CPU)+'i486SX';
  191.   i486dxr,
  192.   i486dxv  : CPU_TypeStr := Vendor(CPU)+'i486DX';
  193.   c486slcr,
  194.   c486slcv : CPU_TypeStr := Vendor(CPU)+'486SLC';
  195.   c486r,
  196.   c486v    : CPU_TypeStr := Vendor(CPU)+'486';
  197.   i586r,
  198.   i586v    : CPU_TypeStr := Vendor(CPU)+'Pentium';
  199.   cM1r,
  200.   cM1v       : CPU_TypeStr := Vendor(CPU)+'M1 (586)';
  201.   umcU5sxr,
  202.   umcU5sxv : CPU_TypeStr := Vendor(CPU)+'U5-S';
  203.   umcU5dxr,
  204.   umcU5dxv : CPU_TypeStr := Vendor(CPU)+'U5-D';
  205.   iP24Dr,
  206.   iP24Dv   : CPU_TypeStr := Vendor(CPU)+'P24D (Pentium Overdrive)';
  207.  end;
  208. end;
  209.  
  210. function CoPro_TypeStr;
  211.  var C : Word;
  212.      S : String;
  213.  begin
  214.   C := CPU_Type;
  215.   case FPUType of
  216.    0,1     : S := 'Unknown';
  217.    2       : S := 'None';
  218.    3       : S := WeitStr;
  219.    4       : S := IntelStr+'8087';
  220.    5       : S := IntelStr+'8087'+AndStr+WeitStr;
  221.    6       : S := IntelStr+'i487sx';
  222.    7       : S := IntelStr+'i487sx'+AndStr+WeitStr;
  223.    8       : S := IntelStr+'80287';
  224.    9       : S := IntelStr+'80287'+AndStr+WeitStr;
  225.    $A      : S := CyrStr+'2C87';
  226.    $B      : S := CyrStr+'2C87'+AndStr+WeitStr;
  227.    $C      : S := IntelStr+'80387';
  228.    $D      : S := IntelStr+'80387'+AndStr+WeitStr;
  229.    $E      : S := CyrStr+'3C87';
  230.    $F      : S := CyrStr+'3C87'+AndStr+WeitStr;
  231.    $10     : S := 'Internal';
  232.    $11     : S := 'Internal'+AndStr+WeitStr;
  233.    $12     : S := CyrStr+'4C87';
  234.    $13     : S := CyrStr+'4C87'+AndStr+WeitStr;
  235.    $14     : S := IntelStr+'80287XL';
  236.    $15     : S := IntelStr+'80287XL'+AndStr+WeitStr;
  237.    $16       : S := IITStr+'2C87';
  238.    $17     : S := IITStr+'2C87'+AndStr+WeitStr;
  239.    $18       : S := IITStr+'3C87';
  240.    $19     : S := IITStr+'3C87'+AndStr+WeitStr;
  241.   else
  242.    S := 'Unknown';
  243.   end;
  244.   if (C >= i286) and checkEmu then
  245.    S := S+', Emulated';
  246.   CoPro_TypeStr := S;
  247.  end;
  248.  
  249. function CPUSpeed;
  250.  begin
  251.   CPUSpeed := ((LongInt(Shift)*CPUFix)/Speed(_CPU)+5)/10;
  252.  end;
  253.  
  254. function intCPUSpeed;
  255.  begin
  256.   intCPUSpeed := ((LongInt(Shift)*CPUFix) div Speed(_CPU) + 5) div 10;
  257.  end;
  258.  
  259. end.
  260.